#include <iostream>
#define ls (rt << 1)
#define rs ((rt << 1) + 1)
using namespace std;
const int N = 200000 + 10;
int Pos[N], Val[N], Ans[N];
struct SegTree {
  int sum[N * 4];
  inline void maintain(int rt) { sum[rt] = sum[ls] + sum[rs]; }
  void build(int rt, int l, int r) {
    if (l == r) {
      sum[rt] = 1;
      return;
    }
    int m = (l + r) / 2;
    build(ls, l, m);
    build(rs, m + 1, r);
    maintain(rt);
  }
  void update(int rt, int l, int r, int pos, int x) {
    if (l == r) {
      Ans[l] = x;
      sum[rt] = 0;
      return;
    }
    int mid = (l + r) / 2;
    if (sum[ls] >= pos)
      update(ls, l, mid, pos, x);
    else
      update(rs, mid + 1, r, pos - sum[ls], x);
    maintain(rt);
  }
} ST;
int main() {
  for (int n; scanf("%d", &n) == 1; puts("")) {
    ST.build(1, 1, n);
    for (int i = 1; i <= n; ++i) scanf("%d%d", &Pos[i], &Val[i]);
    for (int i = n; i >= 1; --i) ST.update(1, 1, n, Pos[i] + 1, Val[i]);
    for (int i = 1; i <= n; ++i) printf("%d ", Ans[i]);
  }
}
